import Vue from "vue";
import VueRouter from "vue-router";
import AdminLayout from "../layout/AdminLayout.vue"
/** * 重复路由 */
const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error);
};
Vue.use(VueRouter);
let envName = process.env.NODE_ENV
let envNameStatus = true
if (envName === 'development' || envName === 'online') {
  envNameStatus = false
} else {
  envNameStatus = true
}
export const routes = [
  // 项目首页路由
  {
    path: "/",
    name: "project",
    component: AdminLayout,
    redirect: "/login",
    meta: {
      keepAlive: false
    },
    children: [
      {
        path: "homePage",
        name: "首页",
        meta: {
          icon: require("@/assets/img/home.png"),
          iconSelect: require("@/assets/img/homeSelect.png"),
          name: "首页",
          show: true,
          parentPath: '/',
          main: true
        },
        component: () => import("@/views/devportal")
      },
      {
        path: "projectManage",
        name: "列表控件",
        meta: {
          icon: require("@/assets/img/proManage.png"),
          iconSelect: require("@/assets/img/manageSelect.png"),
          title: "PLM生命周期管理",
          name: "列表控件",
          show: true,
          parentPath: '/',
          main: true,
          keepAlive: true,
        },
        component: () =>
          import("@/views/plmHomePage/projectManage/projectManage"),
        children: [
          {
            path: "createProject",
            name: "创建项目",
            meta: {
              icon: "file-ppt",
              name: "创建项目",
              parentName: '列表控件',
              parentPath: 'projectManage',
              main: true
            },
            component: () => import("@/views/plmHomePage/projectManage/modules/createProject")
          }
        ]
      },
      {
        path: "reportTool",
        name: "报表工具",
        meta: {
          icon: require("@/assets/img/report.png"),
          iconSelect: require("@/assets/img/reportSelect.png"),
          name: "报表工具",
          show: true,
          parentPath: '/',
          main: true
        },
        component: () => import("@/views/plmHomePage/reportTool"),
        // component: envNameStatus ? () => import("@/views/exception/index") : () => import("@/views/plmHomePage/reportTool"),
        // component: () => import("@/views/exception/index")
      },
      {
        path: "meterPage",
        name: "仪表工具",
        meta: {
          icon: require("@/assets/img/proTool.png"),
          iconSelect: require("@/assets/img/proToolSelect.png"),
          name: "仪表工具",
          show: true,
          parentPath: '/',
          main: true
        },
        component: () => import("@/views/plmHomePage/meterPage")
        // component: () => import("@/views/exception/index")
      },
      {
        path: "toDoPage",
        name: "待办中心",
        meta: {
          icon: require("@/assets/img/waitDeal.png"),
          iconSelect: require("@/assets/img/waitDealSelect.png"),
          name: "待办中心",
          show: true,
          parentPath: '/',
          main: true
        },
        component: () => import("@/views/plmHomePage/toDoPage/toDoPage.vue")
      },
      {
        path: "saveCList",
        name: "C类另存",
        meta: {
          icon: require("@/assets/img/waitDeal.png"),
          iconSelect: require("@/assets/img/waitDealSelect.png"),
          name: "C类另存",
          show: true,
          parentPath: '/',
          main: true
        },
        component: () => import("@/views/plmHomePage/saveCList/saveCList.vue")
      },
    ]
  },
  // 单项目路由
  {
    path: "/single",
    name: "single",
    component: AdminLayout,
    redirect: "/single/projectMain",
    meta: {
      parentPath: '/',
      keepAlive: false
    },
    children: [
      {
        path: "projectMain",
        name: "工作空间",
        meta: {
          icon: require("@/assets/single/singleHome.png"),
          iconSelect: require("@/assets/single/singleHomeSelect.png"),
          name: "工作空间",
          parentName: 'single',
          parentPath: '/single',
          keepAlive: false
        },
        component: () => import("@/views/singleProject/projectMain"),
        children: [
          {
            path: "editProject",
            name: "编辑项目",
            meta: {
              name: "编辑项目",
              parentPath: 'projectMain',
              keepAlive: false
            },
            component: () => import("@/views/singleProject/editProject")
          },
        ]
      },
      {
        path: "projectPlan",
        name: "计划控件",
        meta: {
          icon: require("@/assets/single/singlePlan.png"),
          iconSelect: require("@/assets/single/singlePlanSelect.png"),
          name: "计划控件",
          parentPath: '/single'
        },
        component: () => import("@/views/singleProject/projectPlan")
        // component: envNameStatus ? () => import("@/views/exception/index") : () => import("@/views/singleProject/projectPlan")
      },
      
      {
        path: "fileSingle",
        name: "文件控件",
        meta: {
          icon: require("@/assets/single/singleFile.png"),
          iconSelect: require("@/assets/single/singleFileSelect.png"),
          name: "文件控件",
          parentName: 'single',
          parentPath: '/single'
        },
        component: () => import("@/views/singleProject/fileSingle/"),
        // component: () => import("@/views/exception/index"),
        // component: envNameStatus ? () => import("@/views/exception/index") : () => import("@/views/singleProject/fileSingle"),
        children: [
          {
            path: "examineProject",
            name: "查看交付物",
            meta: {
              name: "查看交付物",
              parentName: '文件控件',
              parentPath: '/fileSingle'
            },
            component: () => import("@/views/singleProject/fileSingle/examineProject")
            
          },
          {
            path: "fileStart",
            name: "文档签审",
            meta: {
              name: "文档签审",
              parentName: '文件控件',
              parentPath: '/fileSingle'
            },
            // component: () => import("@/views/singleProject/fileSingle/fileStart")
            component: () => import("@/views/singleProject/fileSingle/module/fileProcess")
            
          }
        ]
      },
      {
        path: "projectAlteration",
        name: "变更控件",
        meta: {
          icon: require("@/assets/single/singleChange.png"),
          iconSelect: require("@/assets/single/singleChangeSelect.png"),
          name: "变更控件",
          parentPath: '/single'
        },
        component: () => import("@/views/singleProject/projectAlteration"),
        // component: envNameStatus ? () => import("@/views/exception/index") : () => import("@/views/singleProject/projectAlteration"),
        // // component: () => import("@/views/exception/index"),
        children: [
          {
            path: "createAlteration",
            name: "创建变更",
            meta: {
              name: "创建变更",
              keepAlive: true,
              parentPath: '/projectAlteration'
            },
            component: () => import("@/views/singleProject/projectAlteration/editAlteration/createAlteration")
          },
          {
            path: "editAlteration",
            name: "编辑变更",
            meta: {
              name: "编辑变更",
              parentPath: '/projectAlteration'
            },
            component: () => import("@/views/singleProject/projectAlteration/editAlteration/editAlteration")
          },
          {
            path: "detailAlteration",
            name: "查看变更",
            meta: {
              name: "查看变更",
              parentPath: '/projectAlteration'
            },
            component: () => import("@/views/singleProject/projectAlteration/detailAlteration")
          },
          {
            path: "changeAlteration",
            name: "变更处理",
            meta: {
              name: "变更处理",
              parentPath: '/changeAlteration'
            },
            component: () => import("@/views/singleProject/projectAlteration/changeAlteration")
          },
        ]
      },
      {
        path: "partsBOM",
        name: "零部件及BOM管理",
        meta: {
          icon: require("@/assets/single/singleHome.png"),
          iconSelect: require("@/assets/single/singleHomeSelect.png"),
          name: "零部件及BOM管理",
          parentPath: '/single',
        },
        component: () => import("@/views/singleProject/classCOrder/partsBOM"),
        children: [
          {
            path: "orderCList",
            name: "C类订单另存",
            meta: {
              name: "C类订单另存",
              parentPath: 'partsBOM',
              keepAlive: false
            },
            component: () => import("@/views/singleProject/classCOrder/orderCList")
          },
        ]
      },
    ]
  },
  {
    path: "/agree",
    name: "agree",
    component: () => import("@/views/agreement")
  },
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login.vue")
  }
];
const router = new VueRouter({
  routes
});
export default router;